﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI
{
    public class ServiceResult<T>
    {
        public bool IsSuccess { get; private set; }

        public int ErrorCode { get; private set; }

        public string Message { get; private set; }

        public T Data { get; private set; }

        public Exception ErrorException { get; private set; }

        public ServiceResult(bool isSuccess, int errorCode, string message)
        {
            IsSuccess = isSuccess;
            ErrorCode = errorCode;
            Message = message;
        }

        public ServiceResult(bool isSuccess, int errorCode, string message, T data)
        {
            IsSuccess = isSuccess;
            ErrorCode = errorCode;
            Message = message;
            Data = data;
        }

        public ServiceResult(bool isSuccess, int errorCode, string message, T data, Exception exception)
        {
            IsSuccess = isSuccess;
            ErrorCode = errorCode;
            Message = message;
            Data = data;
            ErrorException = exception;
        }
    }

    public class ListResult<T>
    {
        public bool IsSuccess { get; private set; }

        public int ErrorCode { get; private set; }

        public string Message { get; private set; }

        public List<T> Data { get; private set; }

        public Exception ErrorException { get; private set; }

        public ListResult(bool isSuccess, int errorCode, string message)
        {
            IsSuccess = isSuccess;
            ErrorCode = errorCode;
            Message = message;
        }

        public ListResult(bool isSuccess, int errorCode, string message, List<T> data)
        {
            IsSuccess = isSuccess;
            ErrorCode = errorCode;
            Message = message;
            Data = data;
        }

        public ListResult(bool isSuccess, int errorCode, string message, List<T> data, Exception exception)
        {
            IsSuccess = isSuccess;
            ErrorCode = errorCode;
            Message = message;
            Data = data;
            ErrorException = exception;
        }
    }

    public class PagedList<T>
    {
        public bool IsSuccess { get; private set; }

        public int ErrorCode { get; private set; }

        public string Message { get; private set; }

        public int Start { get; set; }
        public int Limit { get; set; }
        public int Total { get; set; }
        public List<T> Data { get; set; }
        public Exception ErrorException { get; private set; }
        
        public PagedList(bool isSuccess, int errorCode, string message)
        {
            IsSuccess = isSuccess;
            ErrorCode = errorCode;
            Message = message;
        }

        public PagedList(bool isSuccess, int errorCode, string message, int start, int limit, int total,  List<T> data)
        {
            IsSuccess = isSuccess;
            ErrorCode = errorCode;
            Message = message;
            Data = data;
            this.Start = start;
            this.Limit = limit;
            this.Total = total;
        }

        public PagedList(bool isSuccess, int errorCode, string message, Exception exception)
        {
            IsSuccess = isSuccess;
            ErrorCode = errorCode;
            Message = message;
            ErrorException = exception;
        }
    }
}
